//
//  DetailCell.m
//  StationManager
//
//  Created by 张佳强 on 17/3/7.
//  Copyright © 2017年 Helong. All rights reserved.
//

#import "DetailCell.h"

@implementation DetailCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.contentView.backgroundColor = [UIColor colorWithRed:239/255.0 green:239/255.0 blue:244/255.0 alpha:1.0];
        
        self.baseView = [[UIView alloc]init];
        self.baseView.backgroundColor = [UIColor whiteColor];
        self.baseView.layer.cornerRadius = 8;
        self.baseView.layer.borderWidth = 0.5;
        self.baseView.layer.borderColor = [[UIColor blackColor] CGColor];
        [self.contentView addSubview:self.baseView];
        
        self.stationName = [[UILabel alloc]init];
        self.stationName.font = [UIFont systemFontOfSize:12.0];
        self.stationName.numberOfLines = 0;
        [self.baseView addSubview:self.stationName];
        
        self.stationNumber = [[UILabel alloc]init];
        self.stationNumber.font = [UIFont systemFontOfSize:12.0];
        self.stationNumber.textAlignment = NSTextAlignmentRight;
        [self.baseView addSubview:self.stationNumber];
        
        self.location = [[UILabel alloc]init];
        self.location.font = [UIFont systemFontOfSize:12.0];
        self.location.numberOfLines = 0;
        [self.baseView addSubview:self.location];
        
        self.address = [[UILabel alloc]init];
        self.address.font = [UIFont systemFontOfSize:12.0];
        self.address.numberOfLines = 0;
        [self.baseView addSubview:self.address];
        
        self.distance = [[UILabel alloc]init];
        self.distance.font = [UIFont systemFontOfSize:11.0];
        self.distance.textAlignment = NSTextAlignmentRight;
        self.distance.textColor = [UIColor colorWithRed:0.35 green:0.33 blue:0.64 alpha:1.0];
        [self.baseView addSubview:self.distance];
        
        [self.baseView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(@10);
            make.top.equalTo(@0);
            make.right.equalTo(@-10);
            make.bottom.equalTo(@0);
        }];
        
        [self.stationName mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(@10);
            make.top.equalTo(@5);
            make.width.mas_equalTo(160);
            make.height.mas_equalTo(20);
        }];
        
        [self.stationNumber mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(@-10);
            make.top.equalTo(@5);
            make.width.mas_equalTo(100);
            make.height.mas_equalTo(20);
        }];
        
        [self.location mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(@10);
            make.top.equalTo(self.stationName.mas_bottom).offset(5);
            make.width.mas_equalTo(SCREEN_WIDTH-110);
            make.height.mas_equalTo(30);
        }];
        
        [self.address mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(@10);
            make.top.equalTo(self.location.mas_bottom).offset(5);
            make.width.mas_equalTo(SCREEN_WIDTH-10);
            make.height.mas_equalTo(20);
        }];
        
        [self.distance mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(@-10);
            make.top.equalTo(self.stationName.mas_bottom).offset(5);
            make.width.mas_equalTo(70);
            make.height.mas_equalTo(20);
            
        }];
    }
    return self;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

@end
